package com.itstherules.jmsunit;

import java.io.FileNotFoundException;

import org.junit.Assert;
import org.junit.Test;

import com.itstherules.jmsunit.loaders.FileLoader;
import com.itstherules.jmsunit.loaders.ResourceFileLoader;


public class ResourceFileLoadingTest {

	static final String SEPARATOR = System.getProperty("line.separator");

	@Test
	public void canLoadResourceFromRootFolder() throws Exception {
		FileLoader unit = new ResourceFileLoader();
		String reply = unit.load("test.txt");
		Assert.assertEquals("i am some test text", reply);
	}
	
	@Test
	public void canLoadResourceFromRootFolderWithEmptyStringInFile() throws Exception {
		FileLoader unit = new ResourceFileLoader();
		String reply = unit.load("empty_test.txt");
		Assert.assertEquals("", reply);
	}

	@Test
	public void canLoadResourceFromRootFolderWithOneCarriageReturnInFile() throws Exception {
		FileLoader unit = new ResourceFileLoader();
		String reply = unit.load("one_carriage_test.txt");
		Assert.assertEquals(SEPARATOR, reply);
	}
	
	@Test(expected=FileNotFoundException.class)
	public void cannotLoadANonExistantResourceFromRootFolder() throws Exception{
		FileLoader unit = new ResourceFileLoader();
		unit.load("not_a_test.txt");
	}
	
}
